/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xib.parserTools.adaptee;

//import android.util.Xml;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.xml.sax.SAXException;
import xib.parserTools.interfaces.IAdapterParser;
import xib.parserTools.interfaces.IChapterData;
import xib.parserTools.interfaces.IHeaderData;

/**
 *
 * @author Jose Miguel
 */
public class AdapteeParserSaxAndroid implements IAdapterParser {

      /**
     * The information of the header
     */
    private IHeaderData headerData;

    /**
     * The information of the chapters
     */
    private ArrayList<IChapterData> chaptersData;


    public void loadInputStream(InputStream input) throws IOException {
        try {
            parse(input);
        } catch (IOException ex) {
            
            throw ex;
        }
    }

    public IHeaderData getHeader() {
       return headerData;
    }

    public ArrayList<IChapterData> getChapters() {
        return chaptersData;
    }

    private void parse(InputStream input) throws IOException {
        XibDataHandler handler = new XibDataHandler();
        try {
//            Xml.parse(fileInputStream, Xml.Encoding.UTF_8, handler);
            headerData = handler.getHeader();

        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }


    }

}
